package com.example.doctorserver.service.impl;


import com.example.doctorserver.mapper.DoctorMapper;
import com.example.doctorserver.pojo.Doctor;
import com.example.doctorserver.response.TijianException;
import com.example.doctorserver.response.TijianExceptionEnum;
import com.example.doctorserver.service.DoctorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DoctorServiceImpl implements DoctorService {
    @Autowired
    private DoctorMapper doctorMapper;

    @Override
    public Doctor login(Doctor doctor){
        Doctor doc = doctorMapper.login(doctor.getDocCode());
        System.out.println(doc.getPassword());
        if((doc!=null) && (doc.getPassword().equals(doctor.getPassword()))){
            return doc;
        }else {
            //不存在抛出异常
            throw new TijianException(TijianExceptionEnum.PHONE_OR_PASSWORD_IS_WRONG);
        }
    }


}
